package com.mpyy.service.purchase;

import com.mpyy.dao.purchase.SupplierMapperDaoInter;
import com.mpyy.pojo.PurchaseStock;
import com.mpyy.pojo.PurchaseStockDesc;
import com.mpyy.pojo.SaleOrderDesc;
import com.mpyy.pojo.SupplierInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(value = "supplierServiceImpl")
@EnableTransactionManagement
@EnableAspectJAutoProxy
public class SupplierServiceImpl implements SupplierServiceInter{
    //依赖持久层
    @Autowired
    @Qualifier(value = "supplierMapperDaoInter")
    private SupplierMapperDaoInter supplierMapperDaoInter;

    /*供货商选择*/
    @Override
    public List<SupplierInfo> searchSupplierInfo(SupplierInfo supplierInfo) {
        return supplierMapperDaoInter.searchSupplierInfo(supplierInfo);
    }

    /*往来财务列表*/
    @Override
    public List<PurchaseStock> searchFinance(PurchaseStock purchaseStock) {
        return supplierMapperDaoInter.searchFinance(purchaseStock);
    }

    /*往来财务列表详情*/
    @Override
    public List<PurchaseStockDesc> searchFinanceDesc(PurchaseStockDesc purchaseStockDesc) {
        return supplierMapperDaoInter.searchFinanceDesc(purchaseStockDesc);
    }

    /*汇总表*/
    @Override
    public List<PurchaseStockDesc> searchcollect(PurchaseStockDesc purchaseStockDesc) {
        return supplierMapperDaoInter.searchcollect(purchaseStockDesc);
    }

    /*流水表*/
    @Override
    public List<PurchaseStockDesc> searchStream(PurchaseStockDesc purchaseStockDesc) {
        return supplierMapperDaoInter.searchStream(purchaseStockDesc);
    }

    /*商品销售情况*/
    @Override
    public List<SaleOrderDesc> searchSaleOrderDesc(SaleOrderDesc saleOrderDesc) {
        return supplierMapperDaoInter.searchSaleOrderDesc(saleOrderDesc);
    }

    @Override
    public List<SupplierInfo> searchAccounting(SupplierInfo supplierInfo) {
        return supplierMapperDaoInter.searchAccounting(supplierInfo);
    }

    @Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
    @Override
    public int updateStockRetreat(PurchaseStock purchaseStock) {
       supplierMapperDaoInter.updatePurchaseStock(purchaseStock);
       supplierMapperDaoInter.updatePurchaseStockDesc(purchaseStock);
       supplierMapperDaoInter.updatePurchaseReturn(purchaseStock);
       supplierMapperDaoInter.updatePurchaseReturnDesc(purchaseStock);
        return 0;
    }
}
